#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>

void InsertSort(int* a, int n)
{
	for (int i = 0; i < n - 1; i++)
	{
		int end = i;
		int tmp = a[end + 1];
		while (end >= 0)
		{
			if (a[end] > tmp)
			{
				a[end + 1] = a[end];
				end--;
			}
			else
			{
				break;
			}
		}
		a[end+1] = tmp;
	}
}


int main()
{
	int a[] = { 6,3,4,9,8,12,61,33,15 };
	int n = sizeof(a) / sizeof(int);

	InsertSort(a,n);

	for (int i = 0; i < n; i++)
	{
		printf("%d ", a[i]);
	}
	return 0;
}